package com.jin.model.entity;

import java.time.LocalDateTime;

import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用户实体类
 */
@Entity
@Table(name = "users")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**
     * 微信openId
     */
    @Column(name = "open_id", unique = true, nullable = false)
    private String openId;
    
    /**
     * 微信unionId
     */
    @Column(name = "union_id")
    private String unionId;
    
    /**
     * 微信sessionKey
     */
    @Column(name = "session_key")
    private String sessionKey;
    
    /**
     * 用户昵称
     */
    @Column(name = "nickname")
    private String nickname;
    
    /**
     * 用户头像URL
     */
    @Column(name = "avatar_url")
    private String avatarUrl;
    
    /**
     * 用户性别 0-未知 1-男 2-女
     */
    @Column(name = "gender")
    private Integer gender;
    
    /**
     * 用户所在学院
     */
    @Column(name = "college")
    private String college;
    
    /**
     * 用户年级
     */
    @Column(name = "grade")
    private String grade;
    
    /**
     * 学力值
     */
    @Column(name = "credit_points", nullable = false)
    private Integer creditPoints = 0;
    
    /**
     * 用户状态 0-正常 1-禁用
     */
    @Column(name = "status", nullable = false)
    private Integer status = 0;

    /**
     * 是否已自定义昵称 0-未自定义 1-已自定义
     */
    @Column(name = "nickname_customized", nullable = false)
    private Integer nicknameCustomized = 0;

    /**
     * 是否已自定义头像 0-未自定义 1-已自定义
     */
    @Column(name = "avatar_customized", nullable = false)
    private Integer avatarCustomized = 0;

    /**
     * 是否已自定义性别 0-未自定义 1-已自定义
     */
    @Column(name = "gender_customized", nullable = false)
    private Integer genderCustomized = 0;

    /**
     * 是否已自定义学院 0-未自定义 1-已自定义
     */
    @Column(name = "college_customized", nullable = false)
    private Integer collegeCustomized = 0;

    /**
     * 是否已自定义年级 0-未自定义 1-已自定义
     */
    @Column(name = "grade_customized", nullable = false)
    private Integer gradeCustomized = 0;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_at", nullable = false)
    private LocalDateTime updatedAt;
}
